/*
 * Created by IntelliJ IDEA.
 * User: zslajchrt
 * Date: Feb 23, 2011
 * Time: 4:32:04 PM
 */
package mycomp.chlor;

import javax.validation.constraints.{Size, Min}
import scaladuct.{Starter, Ref}

class OnePhaseStarter extends Starter[String] {
  def newInstance(): String = {
    phaseOne("ABC")
  }

  def phaseOne(prefix: String) = {
    println("PhaseOne1")
    prefix + "!"
  }

  def destroy(instance: String) {}
}

class TwoPhaseStarter extends Starter[String] {
  private var prefix: String = null

  def newInstance(): String = {
    phaseOne("XYZ")
  }

  def phaseOne(p: String): String = {
    println("PhaseOne2")
    prefix = p
    phaseTwo(0)
  }

  def phaseTwo(count: Int): String = {
    println("PhaseTwo2")
    prefix + count
  }

  def destroy(instance: String) {}
}

class OneReferenceStarter extends Starter[String] {
  def newInstance(): String = phaseOne("XYZ")

  def phaseOne(@Ref(name = "ref1") refString: String): String = {
    refString + "*"
  }

  def destroy(instance: String) = null
}

class OneReferenceStarter2 extends Starter[String] {
  def newInstance(): String = phaseOne("XYZ")

  def phaseOne(@Ref(name = "ref2") refString: String): String = {
    println("RefPhaseOne")
    refString + "*"
  }

  def destroy(instance: String) = null
}